package com.demo;

import java.util.HashMap;
import java.util.Map;

/*
 * 静态工厂方法：直接调用某一个类的静态方法就可以返回Bean的实例
 */
public class StaticAddressFactory {
	private static Map<String, Address> addresses=new HashMap<>();
	
	static{
		addresses.put("first", new Address("beijign", "中南海"));
		addresses.put("second", new Address("yunnan", "西山区"));
	}
	
	public static Address getAddresses(String name) {
		return addresses.get(name);
	}
}
